<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/8 0008
 * Time: 下午 5:35
 */

namespace App\Http\Controllers\Index;


use App\Http\Controllers\Controller;
use App\Model\Article;
use App\Model\Brand;

class IndexController extends Controller
{
    /**
     * @title 首页
     * @param int $type 文章类型
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index($type = 0)
    {
        $where['type'] = $type;
        $list = Article::orderBy('created_at', 'desc')->where($where)->get();
        return view('index.index',['list'=>$list]);
    }

    /**
     * @title  品牌列表接口
     * @return string
     */
    public function brandList()
    {
        $brand_list = Brand::all();
        return json_encode(['state'=>0, 'brand_list'=>$brand_list->toArray()]);
    }
}